home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / net-tools / amitrack / source / amitrackshared.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  4.0 KB  |  107 lines

  1. /* Data and prototypes that are shared by both client and server */
  2.  
  3. #include <libraries/diskfont.h>
  4.  
  5. #define UNLESS(x) if(!(x))
  6.  
  7. #define AMITRACK_TIMEOUT_MINUTES 5
  8.  
  9. /* Possible Request bits for the first data byte of the UDP packets */
  10. #define REQ_COMMENT 0x01    /* "My comment is now this string:" */
  11. #define REQ_BYE        0x02    /* "I'm quitting, remove me immediately" */
  12.  
  13. /* Used internally by the event loops */
  14. #define CODE_UDP_SOCKET    0x0001 /* "You've got a UDP packet ready to read" */
  15. #define CODE_TCP_SOCKET    0x0002 /* "You've got a TCP connection ready" */
  16. #define CODE_TIMER_EXPIRED 0x0004 /* "The timer expired." */
  17. #define CODE_REFRESH       0x0008 /* "Please redraw the client list." */
  18. #define CODE_WINDOW_EVENT  0x0010 /* "Check for IDCMP stuff." */
  19. #define CODE_PING       0x0020 /* "Send a ping, please." */
  20. #define CODE_RECONNECT       0x0040 /* "Possibly reconnect to another server/port" */
  21. #define CODE_ICONIFY       0x0080 /* "Iconify, please." */
  22. #define CODE_MSGPORT       0x0100 /* "A message is at your message port." */
  23.  
  24. /* Since TCP and UDP have separate port domains, I can use the same port numbers
  25.    for the UDP and TCP ports */
  26. #define SERVER_UDP_PORT 18945    /* UDP port for the server process */
  27. #define SERVER_TCP_PORT 18945    /* TCP port for the server process */
  28.  
  29. struct ClientList {
  30.     struct List list;
  31.     int nListLength;
  32. };
  33.  
  34. struct Client {
  35.     struct Node node;
  36.     time_t tDateStamp;
  37.     char * hostname;
  38.     char * comment;
  39.     ULONG ulIPAddress;
  40. };
  41.  
  42. struct TimerStuff {
  43.     struct MsgPort     * TimerMP;
  44.     struct timerequest * TimerIO;
  45.     BOOL BDevOpen;
  46. };
  47.  
  48. struct SocketStuff {
  49.     LONG fd;        /* socket # */
  50.     LONG lSocketType;    /* either SOCK_STREAM or SOCK_DGRAM, please */
  51.     struct sockaddr_in saAddr;
  52. };
  53.  
  54.  
  55. struct WindowStuff {
  56.     struct Screen * screen;        /* Pointer to screen we're on */
  57.     struct Window * win;        /* Pointer to Intuition window structure */
  58.     struct TextAttr font;        /* Gadget rendering font */
  59.     struct TextFont * fontdata;    /* The font's bits */
  60.     struct TextAttr fixedfont;    /* ListView rendering font */
  61.     struct TextFont * fixedfontdata;/* This font's bits */
  62.     struct List   * DisplayList;    /* Our list of strings for the ListView */
  63.     void           * vi;        /* visual info for gadgets */
  64.     struct Gadget * glist;        /* list of all our gadgets */
  65.     struct Gadget * ListGadget;    /* ListView of all logins */
  66.     struct Gadget * PingButton;    /* Manual ping */
  67.     struct Gadget * UpdateButton;    /* Manual update */
  68.     struct Gadget * ServerString;    /* Server display/chooser string */
  69.     struct Gadget * PortString;    /* Port display/chooser string */
  70.     struct Gadget * CommentString;    /* Comment display/chooser string */
  71.     struct Gadget * UpdateIntString;/* Choose list refresh interval */
  72.     struct Gadget * PingIntString;  /* Choose ping interval */
  73. };
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. /* Shared functions */
  81. struct ClientList * SetupClientList(struct ClientList * clientList);
  82. struct TimerStuff * SetupTimer(struct TimerStuff * ts);
  83. struct SocketStuff * SetupSocket(struct SocketStuff * ss, int nPort, LONG lSocketType);
  84.  
  85. ULONG TrackWait(struct SocketStuff * TCPStuff, struct SocketStuff * UDPStuff, struct TimerStuff * Timer, struct WindowStuff * Window, struct MsgPort * msgport);
  86.  
  87. struct Client * NewClient(ULONG ulIPAddress, char * szHostName, char * szOptComment);
  88. void FreeClient(struct Client * client);
  89.  
  90. void ReplaceAllocedString(char ** szOldString, char * szNewString);
  91. void SetTimer(struct TimerStuff * ts, int nSecs, int nMicros);
  92. void TrackExit(char * szMessage, int nCode);
  93.  
  94. struct Client * GetClient(struct ClientList * ClientList, ULONG ulIPAddr, char * szHostName, char * szOptComment);
  95. BOOL RemoveClient(struct ClientList * ClientList, char * szHostName);
  96. BOOL FillInfos(struct SocketStuff * sSocket, char **pSetName, ULONG * ulIPAddress, char **pSetComment);
  97. void PrintClientList(struct ClientList *);
  98. void ClearTrackScreen(void);
  99.  
  100. struct ClientList * GetTrackList(char * szHostName, int nPortNum);
  101.  
  102. int MakeReq(char *sTitle, char *sText, char *sGadgets);
  103.  
  104. char * PastSpaces(char * pcString);
  105. char * RemoveUnprintableChars(char * pcString);
  106. char * RemoveTrailingSpaces(char * pcString);
  107. char * ToLower(char * pcString);